package com.vcc.boss.core.component;

import com.vcc.boss.core.config.AccountConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class SseComponent {

    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private AccountConfig accountConfig;

    @Async
    public void sendRefreshUsableQuotaMessage(Long userId) {
        String url = "http://" + accountConfig.getIp() + "/api/sse/sendRefreshUsableQuotaMessage?userId=" + userId;
        ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
        System.out.println(response.toString());
    }
}
